
package com.wiesloch.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wiesloch.mapper.GoodsMapper;
import com.wiesloch.po.Goods;

/**
 * <p>ClassName:GoodsService</p>
 * <p>Description:商品操作的service类</p>
 * <p> E-mail:jintao_iknow@163.com </p>
 * Date:     2016年5月15日 上午10:06:40 <br/>
 * @author   tao95
 * @version  1.0
 * @since    JDK 1.7
 *
 */
@Service("goodsService")
public class GoodsService {
	
	@Autowired
	private GoodsMapper goodsMapper;
	/**
	 * @description 查询所有的在售商品系列
	 * @return
	 * @throws Exception
	 */
	public List<Goods> selectAllSeries() throws Exception{
		return goodsMapper.selectAllSeries();
	}
	
	/**
	 * @description 根据商品系列的id查询该系列下所有的商品
	 * @return
	 * @throws Exception
	 */
	public List<Goods> selectAllGoodsByPid(Integer goods_pid) throws Exception{
		return goodsMapper.selectAllGoodsByPid(goods_pid);
	}
	
	/**
	 * @description 根剧系列id删除商品
	 * @return
	 * @throws Exception
	 */
	public void deleteGoodsById(Integer goods_id) throws Exception{
		goodsMapper.deleteGoodsById(goods_id);
	}
	
	/**
	 * @description 更新商品的状态(暂停或恢复销售)
	 * @param goods
	 * @throws Exception
	 */
	public void updateGoodsStateById(Goods goods) throws Exception{
		goodsMapper.updateGoodsStateById(goods);
	}
	
	
	/**
	 * @description 插入一条系列数据
	 * @param goods
	 * @throws Exception
	 */
	public void insertSeries(Goods goods) throws Exception{
		goodsMapper.insertSeries(goods);
	}
	
	/**
	 * @description 插入一条商品数据
	 * @param goods
	 * @throws Exception
	 */
	public void insertGoods(Goods goods) throws Exception{
		goodsMapper.insertGoods(goods);
	}

	/**
	 * @description 根据id查找具体某件商品
	 * @param goods_id
	 * @return
	 * @throws Exception
	 */
	public Goods selectGoodsById(Integer goods_id) throws Exception{
		return goodsMapper.selectGoodsById(goods_id);
	}
	
	/**
	 * @description 更新商品系列 
	 * @param goods
	 * @throws Exception
	 */
	public void updateSeries(Goods goods) throws Exception{
		 goodsMapper.updateSeries(goods);
	}
	
	/**
	 * @description 更新商品
	 * @param goods
	 * @throws Exception
	 */
	public void updateGoods(Goods goods) throws Exception{
		goodsMapper.updateGoods(goods);
	}
	/**
	 * @description 查询所有的商品(包括系列)
	 * @return
	 * @throws Exception
	 */
	public List<Goods> selectAllGoods() throws Exception{
		return goodsMapper.selectAllGoods();
	}
}
